package router

import (
	"github.com/gin-gonic/gin"
)

//GET请求路由表
var router_get = map[string]func(*gin.Context){
	"/collect/record": CollectRecordHandle,
	"/website/search": SearchWebsiteHandle,
	"/subscribe/view": SubscribeViewHandle,
	"/article/search": SearchArticleHandle,
	"/collect/search":SearchCollectArticleHandle,
	"/article/scan":   ScanArticleHandle,
	"/article/view_detail":ViewArticleHandle,
}

//POST请求路由表
var router_post = map[string]func(*gin.Context){
	"user/add":      AddUserHandle,
	"user/prof":	 UserProfHandle,
	"subscribe/add": AddSubscribeHandle,
	"subscribe/delete": DeleteSubscribeHandle,
	"collect/add":	 AddCollectHandle,
	"collect/delete":DeleteCollectHandle,
}

func RouterInit() *gin.Engine {
	router := gin.Default()

	//配置路由
	for path, handle := range router_get {
		router.GET(path, handle)
	}
	for path, handle := range router_post {
		router.POST(path, handle)
	}
	return router
}
